import { Application } from 'egg';

export default (app: Application) => {
  const { controller, router } = app;
  // const logger = app.middleware.myLogger({
  //   allowedMethod: [ 'GET' ],
  // }, app)
  const jwtMiddleware = app.jwt as any
  router.get('/', controller.home.index);
  // router.get('/test/:id', controller.test.index)
  router.post('/test/:id', controller.test.index)
  // router.get('/dog', logger, controller.test.getDog)
  router.post('/api/user/create', controller.user.createByEmail);
  // router.get('/api/user/:id', controller.user.show);
  router.get('/api/user/current', app.jwt as any, controller.user.show);
  router.post('/api/user/login', controller.user.loginByCellphone);
  router.post('/api/user/getVeriCode', controller.user.sendveriCode);
  router.get('/api/user/passport/gitee', controller.user.oauth);
  router.get('/api/user/gitee/authorize/callback', controller.user.oauthByGitee);
  router.get('/api/users/getUserInfo', jwtMiddleware, controller.user.show);
  router.post('/api/works', jwtMiddleware, controller.work.createWork)
  router.get('/api/works', jwtMiddleware, controller.work.myList)
  // router.post('/api/works/copy/:id', jwtMiddleware, controller.work.copyWork)
  // router.get('/api/works/:id', jwtMiddleware, controller.work.myWork)
  router.get('/api/templates', controller.work.templateList)
  // router.get('/api/templates/:id', controller.work.template)
  router.patch('/api/works/:id', jwtMiddleware, controller.work.update)
  router.delete('/api/works/:id', jwtMiddleware, controller.work.deleteWork)
  router.post('/api/works/publish/:id', jwtMiddleware, controller.work.publishWork)
  router.post('/api/works/publish-template/:id', jwtMiddleware, controller.work.publishTemplate)
  // router.post('/api/user/getVeriCode', controller.user.sendveriCode)
};
